/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_FLASH.h
 *
 *  Created on: 2022年
 *      Author: 64435
 */

#ifndef HARDWARE_LAYER_INC_LOS_FLASH_H_
#define HARDWARE_LAYER_INC_LOS_FLASH_H_

#include "F021.h"
 
enum e_flash_status
{
    flash_succeed,
    flash_failure,
};
 
struct Sector_List
{
    Fapi_FlashBankType banks_num;
    uint32_t sector_num;
    uint32_t low_addr;
    uint32_t size;
};
 
#define SECTOR_NUM (16+16+32)
 
enum e_flash_status LOS_Flash_EraseSector(Fapi_FlashBankType oNewFlashBank, uint32_t sector);
enum e_flash_status LOS_Flash_EraseBanks(Fapi_FlashBankType oNewFlashBank);
enum e_flash_status LOS_Flash_WriteData(Fapi_FlashBankType oNewFlashBank, uint32_t sector, uint32_t offset, const uint8_t * buff, uint32_t len);
void LOS_Flash_ReadData(Fapi_FlashBankType oNewFlashBank, uint32_t sector, uint32_t offset, uint8_t * buff, uint32_t len);
uint32_t find_sector(Fapi_FlashBankType oNewFlashBank, uint32_t sector);
 
extern struct Sector_List gSector_List[SECTOR_NUM];

#endif /* HARDWARE_LAYER_INC_LOS_FLASH_H_ */
